package com.thyme.rocketmq;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author thyme
 * @ClassName MessageProducer
 * @Description TODO
 * @Date 2019/12/3 21:24
 */
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MessageProducer {

    private final RocketMQTemplate rocketMQTemplate;

    public final static String TOPIC = "thyme";

    public void sendMessage(String message) {
        //发送消息
        log.info("发送的信息为："+ message);
        this.rocketMQTemplate.convertAndSend(TOPIC,message);

    }

}
